
import derelict.sdl.sdl;
import std.c.stdlib;

import maths.Vec;

//TODO: synchronize with riverD
class Events{
	SDL_Event event;

	this(){
	}

	void check(){
		while (SDL_PollEvent(&event)) {
			switch (event.type) {
				// user has clicked on the window's close button
				case SDL_QUIT:
					throw new Exception("KungFuDeathGrip");
					break;
				case SDL_KEYDOWN:
					keyDown(event.key);
					break;
				case SDL_MOUSEBUTTONDOWN:
					mouseDown(event.button);
					break;
				case SDL_MOUSEBUTTONUP:
					mouseUp(event.button);
					break;
				case SDL_MOUSEMOTION:
					mouseMotion(event.motion);
					break;
				// by default, we do nothing => break from the switch
				default:
					break;;
			}
		}
	}

	private void keyDown(SDL_KeyboardEvent e){
//		if(e.keysym.sym == SDLK_ESCAPE) throw new Exception("KungFuDeathGrip");
		if(e.keysym.sym == SDLK_ESCAPE) exit(0);
	}

	private void mouseUp(SDL_MouseButtonEvent e){
	}

	private void mouseDown(SDL_MouseButtonEvent e){
	//	if(e.button == SDL_BUTTON_LEFT){
	//	}
	//	if(e.button == SDL_BUTTON_RIGHT){
	//	}
	//	e.x e.y	
	}

	private void mouseMotion(SDL_MouseMotionEvent e){
	//e.x e.y;
	}

}
